#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''=================================================
@Project -> File   ：try -> 三层神经网络
@IDE    ：PyCharm
@Author ：csl_forever
@Date   ：2020/9/12 20:47
@Desc   ：
=================================================='''

import numpy as np
from 阶跃函数 import sigmod

x = np.array([1.0, 0.5])
w1 = np.array([[0.1, 0.3, 0.5], [0.2, 0.4, 0.6]])
b1 = np.array([0.1, 0.2, 0.3])

# print(w1.shape)
# print(x.shape)
# print(b1.shape)
a1 = np.dot(x, w1) + b1
z1 = sigmod(a1)
# print(a1)
# print(z1)
w2 = np.array([[0.1, 0.4], [0.2, 0.5], [0.3, 0.6]])
b2 = np.array([0.1, 0.2])
a2 = np.dot(z1, w2) + b2
z2 = sigmod(a2)


def identity_function(x):
    return x


w3 = np.array([[0.1, 0.3], [0.2, 0.4]])
b3 = np.array([0.1, 0.2])
a3 = np.dot(a2, w3) + b3
y = identity_function(a3)
print(y)


def softmax(a):
    c = np.max(a)
    exp_a = np.exp(a - c)  # 解决溢出
    sum_exp_a = np.sum(exp_a)
    y = exp_a / sum_exp_a
    return y
